package com.sj.common.dto.menu;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: xiaoqi
 * Date: 2022-03-23
 * Time: 下午 16:41
 * Description: 菜单数据模型
 *
 * @author xiaoqi
 * @since 2022-03-23
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("菜单模型数据")
public class SysMenuDto implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("菜单id 自增长")
    private Integer id;

    @ApiModelProperty("父菜单id 如果没有为0")
    @NotNull(message = "父菜单id不能为空")
    private Integer parentId;

    @ApiModelProperty("菜单名")
    @NotBlank(message = "菜单名不能为空")
    private String name;

    @ApiModelProperty("菜单路径")
    private String path;

    @ApiModelProperty("权限")
    @NotBlank(message = "权限不能为空")
    private String perms;

    @ApiModelProperty("组件路径")
    private String componentPath;

    @ApiModelProperty("类型 0 目录 1 菜单 2 按钮")
    @NotNull(message = "类型不能为空")
    private Integer type;

    @ApiModelProperty("图标")
    private String icon;

    @ApiModelProperty("排序")
    private Integer orderNum;

    @ApiModelProperty("是否启用 1 启用 0 禁用")
    private Boolean status;

    @ApiModelProperty("子菜单")
    private List<SysMenuDto> children;

    @ApiModelProperty("是否有子菜单")
    private Boolean hasChildren;

    @ApiModelProperty("创建时间")
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime createTime;

    @ApiModelProperty("更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime updateTime;

}